home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
awe2-0_1.lha
/
awe2-0.1
/
Src
/
RCS
/
Barrier.cc,v
< prev
next >
Wrap
Text File
|
1989-05-04
|
3KB
|
204 lines
head 3.2;
branch ;
access ;
symbols ;
locks grunwald:3.2; strict;
comment @@;
3.2
date 89.02.20.15.32.04; author grunwald; state Exp;
branches ;
next 3.1;
3.1
date 88.12.20.13.48.31; author grunwald; state Exp;
branches ;
next 1.3;
1.3
date 88.10.30.13.04.20; author grunwald; state Exp;
branches ;
next 1.2;
1.2
date 88.09.28.22.13.17; author grunwald; state Exp;
branches ;
next 1.1;
1.1
date 88.09.18.16.42.18; author grunwald; state Exp;
branches ;
next ;
desc
@@
3.2
log
@Start using Gnu library heaps for schedulers
@
text
@// This may look like C code, but it is really -*- C++ -*-
//
// Copyright (C) 1988 University of Illinois, Urbana, Illinois
//
// written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
//
#include "Barrier.h"
#include "CpuMultiplexor.h"
#include "Thread.h"
Barrier::~Barrier()
{
}
void
Barrier::releaseAll()
{
while ( ! pPileOfThreads.isEmpty() ) {
Thread *p = (Thread *) (pPileOfThreads.remove());
if (debugFlag) {
cerr << "Release " << *p << "\n";
}
ThisCpu -> add(p);
}
}
//
// Make everyone exit
//
void
Barrier::lowerBarrier()
{
lock.reserve();
generation++;
pCount = 0;
releaseAll();
lock.release();
}
void
Barrier::rendezvous()
{
lock.reserve();
if ( pCount == pHeight-1) {
pCount = 0;
generation++;
releaseAll();
lock.release();
} else {
int gen = generation;
pCount++;
lock.release();
for (int i = 0; i < pLoops; i++) {
if (gen != generation) break;
}
if (gen == generation) {
ThisCpu -> reserveByException( this );
}
}
}
bool
Barrier::reserveByException(Thread *byWho)
{
int blocked = 0;
lock.reserve();
if ( pCount == pHeight) {
pCount = 0;
generation++;
releaseAll();
} else {
pPileOfThreads.add( byWho );
blocked = 1;
}
lock.release();
return( blocked );
}
void
Barrier::height(int newHeight)
{
lock.reserve();
if (pCount >= newHeight) {
pCount = 0;
generation++;
releaseAll();
}
else {
pHeight = newHeight;
}
lock.release();
}
@
3.1
log
@Steay version
@
text
@@
1.3
log
@*** empty log message ***
@
text
@d27 3
d31 10
d44 2
a45 2
if ( count == pHeight-1) {
count = 0;
d51 1
a51 1
count++;
d68 2
a69 2
if ( count == pHeight) {
count = 0;
d79 15
@
1.2
log
@*** empty log message ***
@
text
@d1 6
d8 1
a8 1
#include "HardwareCpu.h"
d23 1
a23 1
ThisCpu -> add(p,0);
d38 1
a54 1
count++;
@
1.1
log
@Initial revision
@
text
@d12 1
a12 1
while ( pPileOfThreads.isEmpty() ) {
d27 1
d31 1
d33 6
a38 1
ThisCpu -> reserveByException( this );
d51 1
@